< previous page page_272 next page >

Page 272
WillChangeRecord
RecordChangeComplete
MoveComplete
If youve used the Jet data control, youll notice one very important difference between that data control and the ADO data control. When youre using the Jet data control, the Change events on the data bound controls occur prior to the Reposition event occurring. The Reposition event is analogous to the MoveComplete event. However, the MoveComplete event will happen before the Change events for the bound controls occur. This means you need to come up with a different mechanism to determine when a change is triggered in a data-bound control. You need to determine whether the change was made by a user typing or moving the data control to a new record.
A method I use to solve this problem is to move all the values into the Tag property of every data-bound control when the user positions to a new record. Then I compare the value in the Tag property with whats in the Text property to see whether theyre different. If the values are different, I know that the user just made the change as opposed to just moving to a new record with the data control.
To accomplish this, I first create a routine to move all the values from the new record into the Tag properties. In the MoveComplete method, I call a routine Ive named ControlsTagLoad():
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub datEmployees_MoveComplete(_
            ByVal adReason As ADODB.EventReasonEnum, _
            ByVal pError As ADODB.Error, _
            adStatus As ADODB.EventStatusEnum, _
            ByVal pRecordset As ADODB.Recordset)
   Debug.Print "MoveComplete"

   If pRecordset.EOF Or pRecordset.BOF Then
   Else
      Call ControlsTagLoad(pRecordset)
   End If

End Sub

 
< previous page page_272 next page >

If you like this book, buy it!